require "Common/define"
require "Logic/Config"
require "Common/functions"

RedDotsChatHandler = {};
local this = RedDotsChatHandler;
function RedDotsChatHandler.init()
    CloseEvent(Config.EventType.Fresh_Chat, this.update);
    CloseEvent(Config.EventType.Fresh_Chat_Red, this.update);
    ListenEvent(Config.EventType.Fresh_Chat, this.update);
    ListenEvent(Config.EventType.Fresh_Chat_Red, this.update);

    return this;
end

--参数1： id，nil检查所有
function RedDotsChatHandler.getFlag(...)
    local msgId = ...;
    local flag = Config.RedDotsFlagState.None;
    if logicMgr.ChatManager.CheckMsgIdIsNew(msgId) then
        flag = Config.RedDotsFlagState.Needful;
    end
    return flag;
end

function RedDotsChatHandler.update()
    RedDotsManager.addBroadcast(Config.RedDotsType.Chat);
end
